"""
@name : 猜大小游戏.py
@anthor : huyuxuan
@projectname : PycharmProjects
"""
import random

h = 0
right = 0
error = 0
gold = 1000
while h >= 0:
    a = random.randint(1, 6)
    b = random.randint(1, 6)
    c = random.randint(1, 6)
    sum = a + b + c
    i = input("请猜测3个色子的和为'大'还是为'小'：")
    if i == 'exit':
        print("你一共玩了%d次，胜率为%d%%，金豆剩余%d个" % (h,rate*100,gold))
        break
    elif i == '大':
        if sum >= 11 and sum <= 18:
            gold += 100
            print(f"恭喜你，猜对了，当前金豆数量为{gold}个")
            right += 1
        else:
            gold -= 100
            print(f"你猜错啦，当前金豆数量为{gold}个")
            error += 1
    else:
        if sum >= 3 and sum <= 10:
            gold += 100
            print(f"恭喜你，猜对了，当前金豆数量为{gold}个")
            right += 1
        else:
            gold -= 100
            print(f"你猜错啦，当前金豆数量为{gold}个")
            error += 1
    h += 1
    rate = right / (right + error)
    if gold < 100:
        print("你的金豆数量已低于100个，不能继续玩该游戏")
        break
    elif gold >= 2500:
        print("恭喜你！你的金豆数量已经超过了2500个，可以获得神秘礼品一份！")